# @Time    : 2023/3/20 10:08
# @Author  : SunJian
# @Email   : 330160114@qq.com
# @File    : showfiles.py
# @Software: PyCharm
"""
文件说明：

"""
import os
pathssss = r"D:\jiyun\2208a\meiduo_project\meiduo_mall"

def show_fiels(path):
    files = os.listdir(path)
    for item in files:

        newpath = os.path.join(path, item)  # 拼接出新的路径
        if os.path.isdir(newpath):
            print(newpath)
            # 说明是目录，应该继续遍历
            show_fiels(newpath)
        else:
            # 是文件，应该处理
            if newpath.endswith(".py"):
                num = 0
                comment_num = 0
                with open(newpath,"r",encoding="UTF-8") as f:
                    lines = f.readlines()
                    for line in lines:
                        num += 1
                        if line.startswith("#"):
                            comment_num += 1
                print(newpath,"行数：",num,"; 注释的行数：",comment_num)

show_fiels(pathssss)


